package by.bucha.testproject.app;

import java.util.ArrayList;
import java.util.List;

import com.actionbarsherlock.app.ActionBar;

import android.support.v4.app.Fragment;
import by.bucha.tabnavigationproject.R;
import by.bucha.tabnavigationproject.tabsframework.AbstractTabActivity;
import by.bucha.testproject.fragments.FileExplorerFragment;
import by.bucha.testproject.fragments.ParsedXmlListFragment;
import by.bucha.testproject.fragments.PersonalListFragment;

public class MainTabActivity extends AbstractTabActivity {

	public void addTab(final String title, final Fragment fragment) {
		final ActionBar.Tab tab = getSupportActionBar().newTab();
		tab.setText(title);
		addTab(tab, fragment);
	}

	@Override
	public void createTabs() {
		List<Fragment> startFragments = getStartFragments();
		String tabListIndicator = getResources()
				.getString(
						R.string.main_tab_activity_strings_people_list_tab_list_indicator);
		addTab(tabListIndicator, startFragments.get(0));

		String tabXmlIndicator = getResources()
				.getString(
						R.string.main_tab_activity_strings_people_list_tab_xml_indicator);
		addTab(tabXmlIndicator, startFragments.get(1));

		String tabImageIndicator = getResources()
				.getString(
						R.string.main_tab_activity_strings_people_list_tab_images_indicator);
		addTab(tabImageIndicator, startFragments.get(2));
	}

	@Override
	public List<Fragment> getStartFragments() {
		List<Fragment> startFragments = new ArrayList<Fragment>();

		startFragments.add(new PersonalListFragment());
		startFragments.add(new ParsedXmlListFragment());
		startFragments.add(new FileExplorerFragment());

		return startFragments;
	}
}
